package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.declare.cebWaybill.request.CebWaybillQueryRequest;
import com.dwms.entity.declare.cebWaybill.request.CebWaybillRequest;
import com.dwms.entity.declare.cebWaybill.response.CebWaybillResponse;
import com.dwms.feign.declare.CebWaybillFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: CebWaybillController
 * @Description: CebWaybill
 * @Create 2025-09-15 23:06:21
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "运单信息")
@RestController
@RequestMapping(value = "/declare/cebWaybill")
@RequiredArgsConstructor
public class CebWaybillController {

    private final HttpServletRequest request;
    private final CebWaybillFeignClient cebWaybillFeignClient;

    /**
     * 修改
     *
     * @param cebWaybillRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result update(@RequestBody CebWaybillRequest cebWaybillRequest) {
        WebUtil.getAdminRequest(request, cebWaybillRequest);
        return cebWaybillFeignClient.update(cebWaybillRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<CebWaybillResponse>> findPage(@RequestBody CebWaybillQueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return cebWaybillFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request, query);
        return this.cebWaybillFeignClient.findById(query);
    }

}
